home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / progjour / 1989 / 05 / coop.h < prev    next >
C/C++ Source or Header  |  1989-07-03  |  2KB  |  83 lines

  1. /*
  2.     coop.h - contains structures for simulated Objects
  3.  
  4. */
  5.  
  6.  
  7.  
  8. // -----------------------------------------------------------------
  9. // ------------Structure TWLL---------------------------------------
  10. // -----------------------------------------------------------------
  11. //
  12. //  This is our root structure or Super Class.
  13. //
  14.  
  15. struct TWLL {
  16.     struct TWLL *prev;
  17.     struct TWLL *next;
  18.     int     type;
  19. #define DATA    1
  20. #define MY_DATA     2
  21. #define OTHER_DATA 3
  22.   };
  23.  
  24.   
  25. // -----------------------------------------------------------------
  26. // ------------Structure TWLL_HEAD----------------------------------
  27. // -----------------------------------------------------------------
  28. // 
  29. //  This is our header struct for the linked list
  30. //
  31.  
  32. struct TWLL_HEAD {
  33.     struct TWLL *top;
  34.     int   cnt;
  35.     };
  36.  
  37.  
  38. // -----------------------------------------------------------------
  39. // ------------Structure DATA_TWLL----------------------------------
  40. // -----------------------------------------------------------------
  41. //
  42. //  Here is a struct that Inherits two pointers from TWLL.  
  43. //  By always placing TWLL at the beginning then 
  44. //  TWLL functions can make the assumption that both pointers
  45. //  are at the start of the structure.
  46. //
  47.  
  48. struct DATA_TWLL {
  49.     struct TWLL inherit;
  50.     int x;
  51.     int y;
  52.     };
  53.  
  54. // -----------------------------------------------------------------
  55. // ------------Structure MY_DATA_TWLL-------------------------------
  56. // -----------------------------------------------------------------
  57. //
  58. //  Here is a stuct that inherits the two
  59. //  pointers from TWLL and the x and y fields from DATA_TWLL.
  60. //
  61.  
  62. struct MY_DATA_TWLL {
  63.     struct DATA_TWLL inherit;
  64.     char   a[10];
  65.     char   b[10];
  66.     };
  67.  
  68. // -----------------------------------------------------------------
  69. // ------------Structure OTHER_DATA_TWLL----------------------------
  70. // -----------------------------------------------------------------
  71. // 
  72. //  Here is one last structure using TWLL and DATA_TWLL.
  73. //  Since it uses the same structure (DATA_TWLL) as MY_DATA_TWLL,
  74. //  this class is a sibling of MY_DATA_TWLL
  75. //
  76.  
  77. struct OTHER_DATA_TWLL {
  78.     struct DATA_TWLL inherit;
  79.     int a;
  80.   };
  81.  
  82.  
  83.